package routers

import (
	"CMETO/controllers/appController"
	middleware "CMETO/middlewares"

	"github.com/gin-gonic/gin"
)

func AppApi(r *gin.RouterGroup) {
	var appLogin appController.AppLoginController
	appLoginRouter := r.Group("/app/login")
	{
		appLoginRouter.POST("/", appLogin.AppLogin)
	}
	var goodsType appController.GoodsTypeController
	goodsTypeRouter := r.Group("/app/goodsType", middleware.JWTAuthPlus())
	{
		goodsTypeRouter.GET("/", goodsType.QueryGoodsTypes)
	}
	var goods appController.GoodsController
	goodsRouter := r.Group("/app/goods", middleware.JWTAuthPlus())
	{
		goodsRouter.GET("/", goods.QueryGoods)
		goodsRouter.GET("/bysort", goods.QueryGoodsBySort)
	}
	var order appController.OrderController
	orderRouter := r.Group("/app/order", middleware.JWTAuthPlus())
	{
		orderRouter.GET("/", order.QueryOrders)
		orderRouter.POST("/", order.AddOrder)
	}
	var about appController.AboutController
	aboutRouter := r.Group("/app/about", middleware.JWTAuthPlus())
	{
		aboutRouter.GET("/", about.GetAbout)
		aboutRouter.PUT("/", about.UpdateAbout)
	}
	var account appController.AccountController
	accountRouter := r.Group("/app/account/check", middleware.JWTAuthPlus())
	{
		accountRouter.GET("/", account.CheckAccount)
	}
	var user appController.UserController
	userRouter := r.Group("/app/user/", middleware.JWTAuthPlus())
	{
		userRouter.PUT("/", user.UpdateUser)
		userRouter.GET("/:id", user.QueryUserById)
	}
	var notice appController.NoticeController
	noticeRouter := r.Group("/app/notice/", middleware.JWTAuthPlus())
	{
		noticeRouter.GET("/", notice.QueryNotices)
	}
	var course appController.CourseController
	courseRouter := r.Group("/app/course/bysort", middleware.JWTAuthPlus())
	{
		courseRouter.GET("/", course.QueryCourses)
	}
	var courseType appController.CourseController
	courseTypeRouter := r.Group("/app/courseType/", middleware.JWTAuthPlus())
	{
		courseTypeRouter.GET("/", courseType.QueryCourseTypes)
	}
}
